/**
 * @file   testHttpUtil.cpp
 * @author wolfhead <wolfhead@wolfhead-laptop>
 * @date   Wed Aug 31 10:10:47 2011
 * 
 * @brief  
 * 
 * 
 */
#include "gtest/gtest.h"
#include <acapella/util/http.hpp>

#include <map>

using namespace acapella;
using namespace acapella::util;

TEST(HttpUtilTest, BuildHttpQueryTest)
{
    std::map<std::string, std::string> param;
    param["key"] = "value";
    param["t t"] = "t t";

    std::string query;
    Http::BuildQuery(param.begin(), param.end(), query);
 
    EXPECT_EQ("key=value&t%20t=t%20t", query);
}


TEST(HttpUtilTest, ParseStrTest)
{
    std::map<std::string, std::string> param;

    Http::ParseStr("action=setup&slotid=100185&channel=www.ku6.com&sdk=js&w_u=http%3A%2F%2Fwww.ku6.com%2F&w_be=firefox&enginetype=dfp&sessionid=c4f4aa05b8a00008731b14401be07c206ea15cba", std::inserter(param, param.begin()));

    EXPECT_EQ("setup", param["action"]);
    EXPECT_EQ("100185", param["slotid"]);
}
